//
//  AllScenicCollectionViewCell.m
//  NBTripe
//
//  Created by 陈曦 on 16/1/15.
//  Copyright © 2016年 Vicki. All rights reserved.
//

#import "AllScenicCollectionViewCell.h"
#import "AllScenicTableViewCell.h"

@interface AllScenicCollectionViewCell ()<UITableViewDelegate, UITableViewDataSource>

@end

@implementation AllScenicCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatTableView];
        
        
        
    }
    return self;
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.tableView.frame = CGRectMake(0, 50, self.width, self.height);
}

-(void)setDataSource:(NSArray *)dataSource {
    if (dataSource) {
        if (_dataSource != dataSource) {
            _dataSource = dataSource ;
        }
    }
    
    [self.tableView reloadData];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.webgg((NSString *)[self.dataSource[indexPath.row] url]);
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    AllScenicTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AllScenicTableViewCell"];
    cell.elementModel = self.dataSource[indexPath.row];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            cell.backgroundColor = [UIColor colorWithRed:250/255.0 green:246/255.0 blue:232/255.0 alpha:1];
        cell.titleLabel.textColor = [UIColor blackColor];
        
    
    
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 140.0;
}



- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}

- (void)creatTableView {
    self.tableView = [[UITableView alloc]initWithFrame:self.bounds style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = [UIColor colorWithRed:250/255.0 green:246/255.0 blue:232/255.0 alpha:1];
    [_tableView registerClass:[AllScenicTableViewCell class] forCellReuseIdentifier:@"AllScenicTableViewCell"];
    
    
    [self addSubview:self.tableView];
}






@end
